import api from '/@/utils/request';
import type { RequestConfig } from "/@/api/types/RequestConfig";
import type { RequestParams } from "/@/api/types/RequestParams";
import { AxiosHeaders } from "axios";

export default class Api {
  constructor() {
  }

  static request(params: RequestConfig) {
    return api.request(params);
  }

  static post(param: RequestParams) {
    const params: RequestConfig = { method: "POST", headers: new AxiosHeaders() };
    Object.assign(params, param);
    return this.request(params);
  }

  static  get(param: RequestParams) {
    const params: RequestConfig = { method: "GET", headers: new AxiosHeaders() };
    Object.assign(params, param);
    return this.request(params);
  }

  static put(param: RequestParams) {
    const params: RequestConfig = { method: "PUT", headers: new AxiosHeaders() };
    Object.assign(params, param);
    return this.request(params);
  }

  static delete(param: RequestParams) {
    const params: RequestConfig = { method: "DELETE", headers: new AxiosHeaders() };
    Object.assign(params, param);
    return this.request(params);
  }
}
